package com.gm.file_uploader.utils;

import com.gm.file_uploader.enums.ResultEnums;
import java.io.Serializable;
import lombok.Data;

@Data
public class Result<T> implements Serializable {

  private Integer code;
  private String msg;
  private T data;

  public Result() {
    this.code = ResultEnums.SUCCESS.getCode();
    this.msg = ResultEnums.SUCCESS.getMsg();
  }

  public Result(String msg) {
    this.code = ResultEnums.SUCCESS.getCode();
    this.msg = msg;
  }

  public Result(T data) {
    this.code = ResultEnums.SUCCESS.getCode();
    this.msg = ResultEnums.SUCCESS.getMsg();
    this.data = data;
  }

  public Result(String msg, T data) {
    this.code = ResultEnums.SUCCESS.getCode();
    this.msg = msg;
    this.data = data;
  }

  public Result(Integer code, String msg) {
    this.code = code;
    this.msg = msg;
  }

  public Result(ResultEnums resultEnum) {
    this.code = resultEnum.getCode();
    this.msg = resultEnum.getMsg();
  }

  public Result(Integer code, String msg, T data) {
    this.code = code;
    this.msg = msg;
    this.data = data;
  }
}
